Detection Of UTF-16 Encoding In Streaming  XML Data Without A Byte-Order Mark And Related Printers, Systems, Methods, And Computer Program Products

ABSTRACT

Provided are printers and other electronic devices, systems, methods, and computer program products that automatically detect and determine UTF-16 encoding schemes and endiannesss thereof in an incoming XML data steam for XML declarations without a UTF-16 byte-order mark (BOM) or encoding declaration. This allows for the automatic and unambiguous accurate detection of UTF-16 encoded XML data within a mixed encoding environment, such as from multiple sources using more than one encoding scheme, even when XML data does not start with a BOM or encoding declaration.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.12/047,057 filed Mar. 12, 2008, which claims priority to U.S.Provisional Application No. 60/987,890 filed Nov. 14, 2007, and U.S.Provisional Application 60/988,592 filed Nov. 16, 2007. The contents ofU.S. Patent Applications 60/987,890; 60/988,592; and Ser. No. 12/047,057are hereby incorporated by reference in their entireties.

FIELD OF THE INVENTION

Embodiments of the present invention relate generally to data encodingand decoding and, more particularly, to a printer or other electronicdevice receiving an incoming data steam and automatically detecting anddetermining a UTF-16 encoding scheme, including the endianness of theUTF-16 encoding scheme, for an XML declaration in an incoming XML datastream without a byte-order mark (BOM), and related systems, methods,and computer program products.

BACKGROUND

Extensible Markup Language (XML) has become a readily used and widelyaccepted general-purpose markup language. XML is an open standard thathas been adopted by many business and non-business entities for use in avariety of applications. One notable use of XML is for the sharing ofstructured data across different information systems, such as via theInternet and the World Wide Web (WWW). Greater detail concerning XML maybe found at www.w3.org/XML; in the XML 1.0 standard specification,Extensible Markup Language (XML) 1.0 (Fourth Edition), W3CRecommendation 16 Aug. 2006, edited by Tim Bray, Jean Paoli, C. M.Sperberg-McQueen, Eve Maler, and François Yergeau (available atwww.w3.org/TR/xml/); and in the XML 1.1 standard specification,Extensible Markup Language (XML) 1.1 (Second Edition), W3CRecommendation 16 Aug. 2006, edited by Tim Bray, Jean Paoli, C. M.Sperberg-McQueen, Eve Maler, François Yergeau, and John Cowan (availableat www.w3.org/TR/xml11/), the content of each of which is herebyincorporated by reference in its entirety, including for purposes ofmore fully describing the standard form and use of XML and requirementsfor well-formed XML and valid XML.

Like computers and other computing devices and systems, printers andprinting systems may also use XML data, and notably rather than aproprietary data format and/or a proprietary or fixed single dataencoding scheme. Printing systems, such as for printing barcodes and fortransmitting data to a barcode printer, are widely used. And while manysuch printing systems and printers use proprietary data formats and/orproprietary methods of data encoding and may not be interchangeableand/or compatible with other printing systems and barcode printers, somebeneficial printers and printing systems have been developed that usethe XML data format and readily acceptable data encoding formats, suchas XML data encoded according to UTF-8.

The XML standard specification allows for XML data to be stored usingmultiple character encoding schemes, including but not limited toISO-8859-1, Extended Unix Code for Korean text (EUC-KR), UTF-8, andUTF-16. And the XML standard specification requires that processors ofXML support the Unicode character encodings UTF-8 and UTF-16. Use ofmore limited encodings, such as those based on ISO/IEC 8859 and UTF-32,is acknowledged and is widely used and supported, but is not a mandatoryrequirement of XML specifications. In XML, attributes (also referred toas elements and pseudo-attributes) in a declaration may optionally beincluded, such as an XML declaration that states what version of XML isbeing used. An XML declaration may also contain information aboutcharacter encoding (also referred to as an encoding declaration). Forexample, an XML script may begin with the XML declaration<?xmlversion=“1.0” encoding=“UTF-8”?>, indicating that XML version 1.0 isbeing used and that the encoding is UTF-8. Thus, the primary method usedby computing devices and systems, including printers, to accuratelydetect the encoding used in XML data and thereby decode the XML data isto examine the encoding attribute in the XML declaration at the start ofthe XML data stream, such as <?xml encoding=“UTF-8”?>.

However, this is a problem for UTF-16, which is a non-ASCII transparentbyte serialized encoding scheme that may be either big-endian (BE) orlittle-endian (LE) and, thus, define the order of the bytes in theencoding scheme. Computing devices and systems are not able to decodethe encoding attribute for UTF-16 if it is encoded as UTF-16 unless thecomputing device or system first knows that the incoming XML data isencoded in UTF-16. This presents a logical Catch-22. To resolve thepotential problem, the XML standard specification requires that any XMLdata encoded in UTF-16 must be prefaced with a valid Unicode UTF-16byte-order mark (BOM) described in ISO/IEC 10646 or Unicode with a ZeroWidth No-Break Space character, xFEFF also called a Byte Order Mark(byte sequence FE FF in UTF-16BE and byte sequence FF FE in UTF-16LE).Greater detail concerning character encoding in XML may be found, forexample, in Section 4.3.3, entitled Character Encoding in Entities, inExtensible Markup Language (XML) 1.1 (Second Edition) and in Sections2.5 and 2.6 entitled Encoding Forms and Encoding Schemes in The UnicodeStandard, Version 5.0.

Furthermore, the Unicode standard itself states that the use of a BOM isoptional. This presents another problem for the use of UTF-16 and XML.For example, many utilities that are used to create XML data are Unicodecompliant, but are not necessarily written specifically for XML, andmay, therefore, be valid but not well-formed XML. And, as a result,UTF-16 XML data may not be preceded by the required BOM. The XMLstandard specification provides that it is a fatal error for an entitywhich begins with neither a Byte Order Mark nor an encoding declarationto use an encoding other than UTF-8.

This problem is exacerbated when a computing device or system mustinterpret an incoming data stream of XML data, such as from multiplehosts/sources, each which may be using their own encoding scheme, ratherthan individual XML data files, a single host/source, or multiplehosts/sources using a single, known encoding scheme. For example, acomputing device or system may not be able to detect the presence of thestart of a new XML declaration and/or may not be able to determine theencoding scheme used for the subsequent XML data, particularly where XMLdata is encoded in UTF-16, but no BOM is provided.

A need exists for printers and other electronic devices, systems,methods, and computer program products that may receive an incoming datasteam to unambiguously automatically detect and determine a UTF-16encoding scheme and the endianness thereof for an XML declaration in theincoming XML data stream without a BOM.

SUMMARY

In light of the foregoing background, embodiments of the presentinvention provide printers and other electronic devices, systems,methods, and computer program products that may receive an incoming datasteam and unambiguously automatically detect and determine a UTF-16encoding scheme and the endianness thereof for an XML declaration in theincoming XML data stream without a BOM. As such, embodiments of thepresent invention allow for the automatic and unambiguous accuratedetection of UTF-16 encoded XML data within a mixed encoding environment(e.g., from one or more sources using more than one encoding scheme)even when XML data does not start with a BOM. Embodiments of the presentinvention may be used in any XML and Unicode compliant printer.Embodiments of the present invention are also applicable for use in anyelectronic device or system that may receive XML or another structuredmarkup language and Unicode data streamed from one or more sources usingmultiple encoding schemes into a single port for interpretation.

Embodiments of methods of the present invention are provided thatautomatically detect UTF-16 encoding in an incoming XML data streamwithout a BOM. An exemplary embodiment of the present invention isbriefly described as follows. The embodiment of a method of the presentinvention includes receiving an incoming data stream and monitoring theincoming data stream for the presence of a 0x3C byte. The method mayalso store a current encoding status of the incoming data stream. When a0x3C byte is identified, the embodiment determines if a byte followingthe 0x3C byte is a null 0x00 byte. If the byte following the 0x3C byteis a null 0x00 byte and if the current encoding status is not UTF-16LE,then the embodiment determines if a byte before the 0x3C byte is a null0x00 byte. If the byte before the 0x3C byte is a null 0x00 byte, thenthe embodiment begins processing the incoming data stream as UTF-16BEand stores the current encoding status of the incoming data stream asUTF-16BE. If the byte before the 0x3C byte is not a null 0x00 byte, thenthe embodiment begins processing the incoming data stream as UTF-16LEand stores the current encoding status of the incoming data stream asUTF-16LE. And if the byte following the 0x3C byte is a null 0x00 byteand if the current encoding status is UTF-16LE, then the embodimentdetermines if the two bytes before the 0x3C byte are null 0x00 bytes. Ifthe two bytes before the 0x3C byte are null 0x00 bytes, then theembodiment begins processing the incoming data stream as UTF-16BE andstores the current encoding status of the incoming data stream asUTF-16BE. If the two bytes before the 0x3C byte are not null 0x00 bytes,then the embodiment begins processing the incoming data stream asUTF-16LE and stores the current encoding status of the incoming datastream as UTF-16LE. If the byte following the 0x3C byte is not a null0x00 byte, then the embodiment uses the XML encoding tag to determinethe current encoding status of the incoming data stream from an encodingscheme identified in the XML encoding tag and begins processing theincoming data stream according to the encoding scheme identified in XMLencoding tag. The method may also store the current encoding status ofthe incoming data stream as the encoding scheme identified in XMLencoding tag.

These characteristics as well as additional features, functions, anddetails of the present invention are described below. Similarly,corresponding and additional embodiments of printers and otherelectronic devices and systems and related methods and computer programproducts of the present invention are also described below.

BRIEF DESCRIPTION OF THE DRAWINGS

Having thus described embodiments of the invention in general terms,reference will now be made to the accompanying drawings, which are notnecessarily drawn to scale, and wherein:

FIG. 1 is a schematic block diagram of a printing system according to anembodiment of the present invention;

FIG. 2 is a functional software flow diagram of a method of anembodiment of the present invention; and

FIG. 3 is a schematic block diagram of an entity capable of operating asa printer or other computing device or system in accordance with anembodiment of the present invention.

DETAILED DESCRIPTION

Embodiments of the present invention will now be described more fullyhereinafter with reference to the accompanying drawings, in which some,but not all embodiments of the invention are shown. Indeed, embodimentsof the present invention may be embodied in many different forms andshould not be construed as limited to the embodiments set forth herein;rather, these embodiments are provided so that this disclosure willsatisfy applicable legal requirements. Like reference numbers refer tolike elements throughout.

It will be appreciated from the following that many types of computingdevices and systems may be used with the present invention, including,for example, computers, printers, print servers, Internet servers,routers, mobile telephones, mobile media devices, handheld dataterminals, personal data assistants (PDAs), and other computing devicesand systems. Embodiments of the present invention may be implemented byand/or with printers commercially available from Zebra TechnologiesCorporation of Vernon Hills, Ill., including the following printermodels: XiIII+, 90XiIII+, 96XiIII+, 110XIII+, 140XiIII+, 170XiIII+,220XiIII+, Model Z4M, Z6M, 105SL Model R4Mplus, R402, R-140, and ModelXi series printers. Greater detail concerning those and like printersand corresponding printing systems may be found in U.S. ProvisionalAppl. Ser. No. 60/345,389, filed Jan. 4, 2002, entitled XML PrinterTechnology; U.S. Provisional Appl. Ser. No. 60/341,427, filed Dec. 17,2001, entitled Bar Code Labeling Systems Having Machine ReadableStandards; U.S. application Ser. No. 10/197,014, filed Jul. 17, 2002,entitled Native XML Printer, now U.S. Pat. No. 6,540,142; U.S.application Ser. No. 10/332,604, filed Jan. 10, 2003, entitled XMLPrinter System; U.S. application Ser. No. 11/351,748, filed Feb. 10,2006, entitled XML Printer System; U.S. application Ser. No. 11/774,152,filed Jul. 6, 2007, entitled XML Printer System; U.S. application Ser.No. 10/348,422, filed Jan. 21, 2003; entitled Native XML Printer; U.S.application Ser. No. 10/601,213, filed Jun. 20, 2003, entitled XMLSystem, now U.S. Pat. No. 6,908,034; U.S. application Ser. No.11/010,895, filed Dec. 13, 2004, entitled XML System, now U.S. Pat. No.7,172,122; U.S. application Ser. No. 11/561,084, filed Nov. 17, 2006,entitled XML System; and U.S. application Ser. No. 10/505,982, filedMar. 28, 2006, entitled XML Printer System with RFID Capability, U.S.Provisional Appl. Ser. No. 60/761,610, filed Jan. 24, 2006, entitledGlobal Printing System and Method of Using Same; U.S. application Ser.No. 11/626,670, filed Jan. 24. 2007, entitled Global Printing System andMethod of Using Same, the content of each of which is herebyincorporated by reference in its entirety, including for purposes ofmore fully describing the use and configuration of such printing systemsand printers and use of XML and Unicode data thereby.

Further, while the present invention is described below with referenceto wired direct and networked communications with a printer, the presentinvention is applicable to any form of wired and wireless access andcommunication protocols for establishing communications between any typeand number of computing devices and systems, including, for example,WLAN, Bluetooth (BT), WiMAX, UWB, infrared (IR), and cellular wirelesstechnologies and protocols, serial, parallel, and Ethernet wiredtechnologies and protocols, and IEEE 1394 and USB direct connectiontechnologies and protocols. Further, embodiments of the presentinvention may function with any type of co-located (coexistent orproximate) or distributed (remote) architecture. Computing devices neednot be physically co-located. Similarly, embodiments of the presentinvention may use shared hardware (e.g., processor, memory, and power)or software (e.g., operating system, firmware, software print drivers,print rendering subsystems, and applications) or may use separatehardware, whether co-located or distributed.

It will be appreciated that embodiments of the present invention may beparticularly useful for printing applications with multiple hosts and/orsources (collectively referred to herein as sources). However,embodiments of the present invention are not limited to suchmulti-source printing applications, but may be applied in any type ofenvironment, including single- and multi-source environments, and forany type of application, including printing, Internet, file transfer,streaming multimedia, and other data transfer applications.

And further, while the present invention is described below withreference to XML data, the present invention may be implemented in likemanner with respect to other structured markup languages and scripts,such as ZPL and HMTL, with known starting identifiers, such how validXML data must start with an XML declaration that begins with “<?xml”, orat least known beginning tag statement start identifiers, such as howvalid HTML tags begin with “<”.

The terms ASCII transparent and ASCII transparency are terms used hereinthat refer to an encoding scheme property in which the bytes used torepresent the first 128 characters are the same as in the ASCIIstandard. Examples of ASCII transparent encoding schemes are ASCII,GB2312, and UTF-8.

Embodiments of the present invention provide printers and otherelectronic devices, systems, methods, and computer program products ofembodiments of the present invention that automatically detect anddetermine UTF-16 encoding schemes and endiannesss thereof in an incomingXML data steam for XML declarations without a UTF-16 byte-order mark(BOM) or encoding declaration. This allows for the automatic andunambiguous accurate detection of UTF-16 encoded XML data within a mixedencoding environment, such as from multiple sources using more than oneencoding scheme, even when XML data does not start with a BOM orencoding declaration. This also allows for support of legacy devices andsystems that use different Unicode and proprietary encoding schemes anddevices and systems that are not XML compliant, i.e., such as devicesand systems that are not configured to include a BOM for UTF-16 encodedXML data.

Referring now to FIG. 1, an exemplary embodiment of a high-levelschematic block diagram of a printer 250 according to an embodiment ofthe present invention is shown in communication with various additionaldevices, including a computer system 112. The printer 250 is connect tothe computer system 112, which itself includes various hardwarecomponents, such as RAM 114, ROM 116, hard disk storage 118, cachememory 120, database storage 122, and the like (referred to collectivelyas storage or memory, and depicted as a storage or memory subsystem126), as is known in the art. The printer 250 and computer system 112combination may collectively be referred to as a printing system. Theprinter 250 and computer system 112 may be combined in a commonenclosure (coexistent), but need not necessarily be constructed in thismanner. For example, the computer system 112 may be housed in anenclosure separate and apart from the printer 250, such that the twodevices are proximately co-located. The combination printing system maynot be recognized as two separate devices and/or may be considered asingle device, and thus, referred to individually as a printer orprinting system. When housed in separate enclosures, whether proximateor remote from each other, the two devices may be referred to separatelyas a printer and a computer. Further, when the printer 250 comprises allnecessary hardware and firmware and is configured to operateindependently of any particular computer system 112, 112 a . . . 112 nor other device (e.g., ERP 188), the computer system 112 is like anyother host or source of data for the printer, such as computer systems112 a . . . 112 n and ERP 188. The relationship of such devices is notparticular to embodiments of the present invention.

The computer system 112 may include any suitable processing device 128,such as a computer, microprocessor, RISC processor (reduced instructionset computer), CISC processor (complex instruction set computer),mainframe computer, work station, single-chip computer, distributedprocessor, server, controller, micro-controller, discrete logiccomputer, or like processor, as are known in the art. For example, theprocessing device 128 may be an Intel Core™ or Pentium® microprocessor,other x86 compatible microprocessor, or equivalent processing device.

The memory subsystem 126 may include any suitable storage components,such as RAM 114, ROM 116, EPROM (electrically programmable ROM), flashmemory, dynamic memory, static memory, FIFO (first-in first-out) memory,LIFO (last-in first-out) memory, circular memory, semiconductor memory,bubble memory, buffer memory, hard disk memory 118, optical memory,cache memory 120, database memory 122, and the like, as are known in theart. Any suitable form of memory or storage or memory subsystem 126 maybe used whether fixed storage on a magnetic medium, storage in asemiconductor device, or remote storage accessible through acommunication link.

A user interface 130 may be included in or coupled to the computersystem 112 and may include various user input devices 136, such asbuttons or switches selectable by the user, a keyboard, a mouse, a touchscreen, bar code scanner, RFID reader (or reader/writer), or like userinput devices, as are known in the art. The user interface 130 also mayinclude one or more suitable user output devices 140, such as an LCDdisplay, a CRT, various LED indicators, a speech output device, and likedata output presentation devices, as are known in the art.

To communicate between the computer system 112 and external sources, acommunication interface 142 may be operatively included in or coupled tothe computer system 112. The communication interface 142 may be, forexample, as shown for computer system 112, an interface for a directconnection to a printer 250 or, as shown for computer systems 112 a . .. 112 n , an interface for a connection to a local area network, anEthernet network, an intranet, or other suitable network 144. Acommunication interface may also be connected to a public switchedtelephone network (PSTN) or POTS (plain old telephone system), which mayfacilitate communication with a network 144 or direct connection to aprinter 250. Dedicated and remote networks may also be employed. Anysuitable commercially available communication device or network may beused, as is known in the art.

As described above, a computer system 112, 112 a . . . 112 n may becoupled to a printer 250. A printer 250 may be an XML printer for whichthe native or natural “language” of the system is XML and, thus,referred to as a “native XML printer.” The printer 250 includes aprocessor 228, and may also include additional computing hardware shownand described more fully with respect to the computing system 112 andthe entity of FIG. 3. The printer 250 may include a media/paper controlsystem 252, a print rendering subsystem 254 (such as including a printdriver or print rendering driver, not to be confused with a softwareprint driver), and a print head mechanism 256. Any suitable printercapable of printing barcode labels may be used, which may includevarious dot matrix, ink jet, laser and/or thermal printers. Suchsuitable printers, for example, are available from Zebra TechnologiesCorporation of Vernon Hills, Ill., and may include the Model Xi seriesbarcode printers (XiIII+, 90XiIII+, 96XiIII+, 110XiIII+140XiIII+,170XiIII+, 220XiIII+, etc.), the 2800 Series barcode printers, ModelZ4M, Z6M, 105SL barcode printers, Model R4Mplus, R402, R-140printer/encoders, and others. Further, printers not specificallydesigned for printing barcodes may also serve for embodiments of thepresent invention. Barcode printers are used as examples herein becauseof the specific applicability of the use of XML for communicating withbarcode printers and the use of XML stylesheets by barcode printers.

Alternatively, or in addition, the printer 250 may include a“non-printing” mechanism to handle the programming of RFID (radiofrequency identification) or like electronic media, which may alsoreceive printed labeling or other printed indicia on its surface. Forexample, a printer 250 may include an RFID transceiver 261 to operate inconjunction with RFID media or and RFID transponder 182. The term“printer” is meant to include systems that also include RFID read and/orwrite capability although the “RFID” may not be part of the term.Additionally, although the term “barcode labels” are used herein, thisterm is not limited to a paper label, and may include, for example,tickets, tags, cards, sheet fed paper, continuous and fanfold paper,plastic media, media embedded with RFID circuits, and other automaticidentification devices. The present invention applies to different typesof media, just as it applies to different types of printers, and othercomputing devices, entirely.

Typically, such printers may include various motors, label cutters,ribbon handlers, sensors, and the like, as are shown in the art.Additionally, such printers may include various control inputs orsensors, such as a media sensor, print head temperature sensor, headopen sensor, ribbon sensor, and the like, as are known in the art. Theprinter 250 may include one or more additional processors, other thanthe processor 228, such as processor 128 residing in the computer system112. Alternatively, the processor 128 in the computer system 112, ifsufficiently powerful, may control and handle the printer 250 functionswithout the need for a separate processing device in the printer, suchas processor 228. Thus, all functions of the printer 250 may becontrolled by a computer or processor physically separate from theprinter. Greater detail concerning the control of the print-head may befound in U.S. Pat. No. 5,372,439 entitled “Thermal Transfer Printer withControlled Ribbon Feed,” issued Dec. 13, 1994, the content of which ishereby incorporated by reference in its entirety. Typically, however, aprinter will include a processor.

The RFID transceiver 261 may be configured to communicate with an RFIDtransponder 182 and read or program the RFID transponder. RFIDtransponder 182 may be of the “chip” or “chipless” type, and one commonform of such an RFID transponder, which is often used in “smart labels,”includes an antenna and an RFID integrated circuit. Such RFIDtransponders 182 include both DC powered active transponders andbattery-less passive transponders, and are available in a variety ofform factors. The terms “barcode printer” and “barcode system” are usedinterchangeably herein with the term “barcode/RFID system,” “XML system”and the like, and such a system includes the capability to encode RFIDdata into an RFID transponder, even though the term “RFID” may notnecessarily be part of the identifying text. Greater detail regardingRFID transponders may be found in U.S. application Ser. No. 10/001,364,entitled Method And Apparatus For Associating On Demand Certain SelectedMedia And Value-Adding Elements, filed Oct. 25, 2001, the content ofwhich is hereby incorporated by reference in its entirety.

A user interface 230 may be included in or coupled to the printer 250and may include various user input devices 136, such as buttons orswitches selectable by the user, a keyboard, a mouse, a touch screen,bar code scanner, RFID reader (or reader/writer), or like user inputdevices, as are known in the art. The user interface 230 also mayinclude one or more suitable user output devices 140, such as an LCDdisplay, a CRT, various LED indicators, a speech output device, and likedata output presentation devices, as are known in the art.

To communicate between the printer 250 and external sources, such as acomputer system 112, 112 a . . . 112 n, a communication interface 242may be operatively included in or coupled to the printer 250. Thecommunication interface 242 may be, for example, as shown for printer250, an interface for a direct connection to a computer system 112 or aninterface for a connection to a local area network, an Ethernet network,an intranet, or other suitable network 144. A communication interfacemay also be connected to a public switched telephone network (PSTN) orPOTS (plain old telephone system), which may facilitate communicationwith a network 144 or direct connection to a computer system 112, 112 a. . . 112 n or other device. Dedicated and remote networks may also beemployed. Any suitable commercially available communication device ornetwork may be used, as is known in the art. As noted above, in additionto a computer system 112, 112 a . . . 112 n, the communication interface242 may provide direct or indirect and wired or wireless communicationwith other devices, such as an external hard drive, a removable memorydevice, such as a USB flash drive, or other storage device, an RFID tagreader, a barcode scanner, another printer, and other sources of data.Any device in communication with the printer 250 via the communicationinterface 242 may be a source of incoming data, such as for an incomingXML data stream to the printer 250, including, for example, XML printdata stored in a print server, USB flash drive, or other device andtransmitted to the printer 250 via the communication interface 242.

Also shown is an enterprise resource planning (ERP) system 188, whichmay be, for example, a warehouse management system that transmits XMLdata to the printer 250, either directly or via a network 144. An ERPsystem 188 may initiate a request to print information, such as barcodelabels, or to encode information, such as RFID data. Of course, likecomputer systems 112, 112 a . . . 112 n, any enterprise computer systemmay be used, and this invention is not limited to use with any specifictype of enterprise computer system.

The above description related to FIG. 1 showing an exemplary embodimentof a high-level schematic block diagram of a printer 250 according to anembodiment of the present invention helps to recognize that moderncomputing devices and systems may be configured in any number of waysand involving multiple devices and systems. As such, when varioussystems may be configured to transmit data to each other in variousencoding schemes, it is important that the receiving device be able toidentify the encoding scheme of received data and decode the receiveddata according to the paper encoding scheme. This is particularlyrelevant to non-ASCII transparent encoding schemes. And, as describedabove, without the proper identification of the encoding scheme, such asin a BOM or other encoding declaration, the receiving device may beunable to property decode the received data or, in the case of streamingdata, may even be unable to detect the start of data encoded in adifferent encoding scheme than the previous data. This problem isspecifically applicable to XML data encoded in UTF-16 without a BOM.Embodiments of the present invention solve this problem.

Referring now to FIG. 2, an embodiment of a functional software flowdiagram is illustrated. The functions described by each block may beencoded in control logic (software code) stored on a computer-readableand computer-useable medium, thereby creating a computer programproduct. The functions of FIG. 2 are collectively referred to herein asa detection module, as depicted in FIG. 3 as detection module 330.Although, individual functions may be encoded in separate control logicand/or stored at and on separate computer-readable mediums. Thearchitecture of a detection module is not particular to embodiments ofthe present invention. The functions may be part of firmware, software,or other control logic, which are collectively referred to in generalherein interchangeably as software, functions, and software functionswithout specificity to the type of computer-readable medium in which thesoftware, function, or software functions are stored in encoded controllogic.

The software described below with respect to FIG. 2 may be executed bythe processor 228 of the printer 250 of FIG. 1 or, depending upon therelationship between the printer 250 and the computer system 112 of FIG.1, by the processor 128 of the computer system 112. Again, the processor128 may perform functions common to both the computer system 112 and theprinter 250, if such a relationship exists between the two devices. Andthere may be one or more processors on either device, which may functionin concert or which may function separately. It is not material to thescope of this invention whether the processing or processing functionsare performed by the computer system 112 or by the printer 250.

Embodiments of the present invention and the flow diagram of FIG. 2 relyupon two underlying principles. First, there is a limited number ofencoding scheme changes that are possible between the data preceding anXML script in an incoming stream of data, also referred to as anincoming XML stream or an incoming XML data stream. Specifically, thereare 18 transition cases in all. These 18 transition cases are detailedbelow. Second, all valid XML scripts, whether well formed or merelyvalid, must start with an XML declaration that begins with “<?xml”.

The following chart identifies the 18 transition cases for a new validXML script in an incoming stream of data. The transitions areabbreviated with a legend presented below the chart for the encodingschemes and BOMs. For each transition case, the previous encodingscheme, carriage return and line feed (CR/LR), BOM, <?xml declarationstart, and new XML encoding scheme are identified. Also, a portion ofthe corresponding process of the flow diagram of FIG. 2 is identifiedwith respect to the determination of each transition case in accordancewith embodiments of the present invention.

Character Return/ Previous Line Encoding Feed New XML FIG. 2 Flow CaseTransition State (CR/LF) BOM <? Encoding Process a A-A ASCII 0d0a 3c3fASCII 44-46-48 Transparent Transparent b B-B UTF-16BE 000d000a 003c003fUTF-16BE 44-60-62-64 c L-L UTF-16LE 0d000a00 3c003f00 UTF-16LE44-60-80-84 d A-L ASCII 0d0a 3c003f00 UTF-16LE 44-60-62-66 Transparent eA-B ASCII 0d0a 003c003f UTF-16BE 44-60-62-64 Transparent f L-B UTF-16LE0d000a00 003c003f UTF-16BE 44-60-80-82 g L-A UTF-16LE 0d000a00 3c3fASCII 44-46-48 Transparent h B-L UTF-16BE 000d000a 3c003f00 UTF-16LE44-60-62-66 i B-A UTF-16BE 000d000a 3c3f ASCII 44-46-48 Transparent jA-FEFF-B UTF-16BE 0d0a feff 003c003f UTF-16BE 44-60-62-64 k A-FFFE-LUTF-16LE 0d0a fffe 3c003f00 UTF-16LE 44-60-80-84 l B-EFBBBF-A ASCII000d000a efbbbf 3c3f ASCII 44-46-48 Transparent Transparent m B-FFFE-LUTF-16LE 000d000a fffe 3c003f00 UTF-16LE 44-60-80-84 n L-FEFF-B UTF-16BE0d000a00 feff 003c003f UTF-16BE 44-60-62-64 o L-EFBBBF-A ASCII 0d000a00efbbbf 3c3f ASCII 44-46-48 Transparent Transparent p B-FEFF-B UTF-16BE000d000a feff 003c003f UTF-16BE 44-60-62-64 q L-FFFE-L UTF-16LE 0d000a00fffe 3c003f00 UTF-16LE 44-60-80-84 r A-EFBBBF-A ASCII 0d0a efbbbf 3c3fASCII 44-46-48 Transparent Transparent A = ASCII Transparent B =UTF-16BE L = UTF-16LE FEFF = UTF-16BE BOM FFFE = UTF-16LE BOM EFBBBF =UTF-8 BOM

By performing a byte level examination of the incoming data stream andlooking for the presence and/or absence of a NULL 0x00 byte at keylocations, embodiments of the present invention are able to uniquelyidentify which of the 18 transition cases the current data streammatches. And each of the 18 transition cases may be used to uniquelyidentify which of the possible encoding schemes are being used (ASCIItransparent, UTF 16BE, or UTF-16LE).

Referring again and more specifically to the flow diagram of FIG. 2, amethod of auto-detection of an XML encoding scheme is presented andfollows the depicted order and decisions of the flow chart. As aprecursor to the method, and as described further below with respect toblock 92, a method of an embodiment of the present invention may relyupon the knowledge of the current encoding scheme for an incoming datastream. As such, a method may begin or be preceded by storing thecurrent encoding scheme of an incoming data stream such as into a memorythat may be called upon, if necessary, during a first pass of the methodbefore block 90, described below, is reached. Storing the currentencoding scheme may be performed, such as using a log file or merelymaintaining an RAM address with an indication of the current encodingscheme. Further, when the current encoding scheme is ASCII transparent,storing the current encoding scheme may simply require that a previouslystored non-ASCII transparent encoding scheme is no longer represented asthe current encoding scheme and, for example, the current encodingscheme is determined by default or in real time by the characteristic ofthe encoding scheme being ASCII transparent. For example, a printer mayfunction in accordance with an embodiment of the present invention bykeeping track of the current encoding scheme and using a method of thepresent invention to detect a change in the current encoding schemewhich is then identified as the current encoding scheme to be kept trackof by the printer. The manner for storing the current encoding scheme isnot particular to embodiments of the present invention.

The method begins as identified by a Start block 10, followed byinitializing (creating and/or starting) and clearing a “first in, firstout” (FIFO) data buffer and FIFO parser buffer, as shown at block 20.The method continues by receiving data from a communication port, asshown at block 22, and by storing the received data in the data buffer,as shown at block 24. The method then continues by moving (transferring)one byte from the data buffer to the parser buffer, as shown at step 26.

The method then arrives at a first decision point at block 40, where adetermination is made regarding whether the current byte in the parserbuffer is a 0x3C byte potentially signifying the 0x3C byte for a “<”character of the beginning of an XML script declaration, such as foundin “<?xml”. For example, in UTF-16BE, a 0x3C byte is found in the twobyte sequence 003C, in UTF-16LE, a 0x3C byte is found in the two bytesequence 3C00, and in UTF-8 and other ASCII transparent encodingschemes, a 0x3C byte represents a “<” character. Thus, for ASCIItransparent encoding, the presence of a 0x3C byte unambiguouslyidentifies a “<” character. For UTF-16BE encoding, the presence of a0x3C byte identifies a “<” character if the preceding byte is a NULL0x00 byte. And for UTF-16LE encoding, the presence of a 0x3C byteidentifies a “<” character if the subsequent byte is a NULL 0x00 byte.Until a 0x3C byte is identified, the decision point at block 40 cyclesin the “NO” direction back to block 26 that then moves the next byte inthe input data stream from the data buffer to the parser buffer.

When a 0x3C byte is identified, the method follows the “YES” directionforward to block 42 in which a subsequent (next or additional) byte inthe input data stream is moved from the data buffer to the parser bufferfor examination. The method continues to a second decision point atblock 44, which separates ASCII transparent encoding schemes from UTF-16encoding schemes. The second decision point at block 44 makes adetermination of whether the current byte in the parser buffer is a NULL0x00 byte, that is, whether the byte following the 0x3C byte is a NULL0x00 byte. If the current byte in the parser buffer is not a NULL 0x00byte, then the method continues in the “NO” direct to block 46, whichidentifies that the XML data is ASCII transparent. Accordingly, themethod continues to block 48, which signifies to use the encoding schemeidentified by the XML encoding attribute that may be read from the XMLdeclaration statement. The method then concludes by storing the currentencoding scheme, as shown in block 90, for potential future use by themethod as described further below, and terminating at the End block 94.

If at the second decision point at block 44, it is determined that thecurrent byte in the parser buffer is a NULL 0x00 byte, then the XML datais not ASCII transparent, but is using an UTF-16 encoding scheme.However, at this point, the byte order (endianness) of the UTF-16encoding scheme is not yet known and must still be determined.Accordingly, the method continues in the “YES” direction to a thirddecision point at block 60.

The third decision point at block 60 is a branch based upon theknowledge of the current encoding scheme of the incoming data stream. Asnoted above, a method of an embodiment of the present invention may relyupon the knowledge of the current encoding scheme for an incoming datastream and does so at the third decision point at block 60. If the XMLdata is ASCII transparent, then the method does not reach block 60, andknowledge of the current encoding scheme is not required. However, ifthe XML data is non-ASCII transparent, then the method must know thecurrent encoding scheme for the previous data in the incoming datastream. As such, a method typically will be preceded by storing and/orconcurrent with identifying the current encoding scheme of the incomingdata stream that may be called upon by the method at the third decisionpoint at block 60. Reference to the “current” encoding scheme of anincoming data stream at the third decision point at block 60 describesthe known encoding scheme of data preceding the 0x3C byte identified atblock 40, referred to herein as “previous data” in the incoming datastream. By comparison, reference to the “current” encoding scheme of anincoming data stream at block 90 describes the encoding schemedetermined by the method and stored in memory for potential future useby the method.

If the previous data in the incoming data stream preceding the 0x3C byteidentified at block 40 was not encoded in UTF-16LE, then the endiannessof the XML data may be determined by examining the single byteimmediately preceding the previously detected 0x3C byte and the methodcontinues in the “NO” direction to block 62 to make this examination anddetermination of the endianness of the encoding scheme. A fourthdecision point at block 62 evaluates the single byte immediatelypreceding the detected 0x3C byte. A determination is made that if thebyte immediately preceding the detected 0x3C byte is a NULL 0x00 byte,then the byte order is big endian and the XML data is encoded usingUTF-16BE, as identified at block 64. Otherwise, a determination is madethat if the byte immediately preceding the detected 0x3C byte is not aNULL 0x00 byte, then the byte order is little endian and the XML data isencoded using the XML data is encoded using UTF16-LE, as identified atblock 66.

If the previous data in the incoming data stream preceding the 0x3C byteidentified at block 40 was encoded in UTF-16LE, then the endianness ofthe XML data may be determined by examining the two bytes immediatelypreceding the previously detected 0x3C byte and the method continues inthe “YES” direction to block 80 to make this examination anddetermination of the endianness of the encoding scheme. A fifth decisionpoint at block 80 evaluates the two bytes immediately preceding thedetected 0x3C byte. A determination is made that if the two bytesimmediately preceding the detected 0x3C byte are NULL 0x00 bytes, thenthe byte order is big endian and the XML data is encoded using UTF16-BE,as identified at block 82. Otherwise, a determination is made that ifthe two bytes immediately preceding the detected 0x3C byte are not NULL0x00 bytes, then the byte order is little endian and the XML data isencoded using UTF-16LE, as identified at block 84.

As discussed above, the method may subsequently rely upon the knowledgeof the current encoding scheme at the third decision point at block 60.Accordingly, after the identification of the encoding scheme for the XMLdata, the method perceived at block 90 stores the current encodingscheme, such as in a memory, as shown at element 92.

After an embodiment of the present invention has automatically detectedthe encoding scheme for the XML data, a proper BOM may be inserted intothe incoming data stream so that the XML data is well formed with theinclusion of a BOM and may be parsed using a standard off-the-shelfparser. The data stream including the BOM may be referred to as anenhanced incoming data stream, which, for example, may be passed toanother device, such as a printer. For example, it may be useful to adda BOM in situations where a print server or software print driver isused with one or more printers, such as where a device receiving theenhanced incoming data stream uses an off-the-shelf parser that reliesupon the presence of BOMs for XML encoded according to a UTF-16 encodingscheme. Also, for example, it may be useful to add a BOM in situationswhere a printer generates a log or transmits XML data from the printerto another device or system, such as for the other device or system togenerate a log or analyze the print data. Such a situation may bepresent, for example, where a printer reads an RFID tag and combines itwith variable data, and a set of XML data is transmitted so an externalcomputer system can correlate the RFID tag with the variable data.

The following description and example is provided to help understand oneof the difficulties and non-intuitive aspects of and functions requiredfor automatically determining the encoding scheme, and particularly theendianness of a UTF-16 encoding scheme. In streaming data, where thebeginning and end of an XML data string (or file) is not unambiguouslyknown, it is also unknown in UTF-16 encoding if a byte is part of thelast character or the beginning of the next character. Thus, unless thecurrent encoding scheme is known for streaming data, the encoding schemeat a transition to a UTF-16 encoding scheme, including the endianness ofthe encoding scheme, may not be determined. So, for example, if thecurrent encoding scheme is UTF-I6BE, then it is sufficient to look atthe single byte preceding the 0x3C byte to determine if the new UTF-16encoding scheme has either a big endian or a little endian byte order.Specifically, if a NULL 0x00 byte precedes the 0x3C byte, then the byteorder is big endian, as in 003C. If a NULL 0x00 byte does not precedethe 0x3C byte, then the byte order is little endian, as in 3C00.However, if the current encoding scheme is UTF-16LE, then it is notsufficient to simply look at the single byte preceding the 0x3C byte todetermine if the new UTF-16 encoding scheme has either a big endian or alittle endian byte order, but requires looking at the two bytespreceding the 0x3C byte to determine if the new UTF-16 encoding schemehas either a big endian or a little endian byte order.

This situation is exemplified in the similarities and differencesbetween transition case c for UTF-16LE to UTF-16LE and transition case ffor UTF-16LE to UTF-16BE. The CR/LF and <? sequences for these twotransition cases are 0d000a00 3c003100 and 00d000a00 003c003f,respectively. A 0x3C byte is present in both cases and followed by aNULL 0x00 byte. And the 0x3C byte is preceded in both cases by a NULL0x00 byte. Thus, to determine whether the new UTF-16 encoding schemefollowing the transition has a big endian or a little endian byte order,the two bytes preceding the 0x3C byte are evaluated. In the transitioncase c for UTF-16LE to UTF-16LE, the 0x3C byte is preceded by a singleNULL 0x00 byte, thus signifying that the 0x3C byte is the first byte ofa 3C00 UTF-16LE character. In the transition case f for UTF-16LE toUTF-16BE, the 0x3C byte is preceded by two NULL 0x00 bytes, thussignifying that the 0x3C byte is the second byte of a 003C UTF-16BEcharacter, where the first preceding NULL 0x00 byte is the first byte ofa 003C UTF-16BE character and the second preceding NULL 0x00 byte is thesecond byte of a 0a00 UTF-16LE Line Feed character.

A method according to an embodiment of the present invention mayevaluate each byte in an incoming data stream to identify a potentialtransition case, but the full extent of a method may only be activatedwhen a 0x3C byte is identified. Alternatively, a method according to anembodiment of the present invention may temporarily suspend monitoringthe incoming data stream for the presence of a 0x3C byte, such as forperiods of time during which no transition and no <?xml declarationstatement is anticipated. For example, a method may temporarily suspendmonitoring the incoming data stream for the presence of a 0x3C bytewhile monitoring the XML data of the incoming data stream for an XMLsyntax error. Upon the detection of an XML syntax error, the method mayresume monitoring the incoming data stream for the presence of a 0x3Cbyte. Similarly, for example, a method may temporarily suspendmonitoring the incoming data stream for the presence of a 0x3C bytewhile monitoring the XML data of the incoming data stream for a closingXML declaration end tag. Upon the detection of a closing XML declarationend tag, the method may resume monitoring the incoming data stream forthe presence of a 0x3C byte.

As another exemplary embodiment of the present invention, a print servermay be employed to automatically detect and determine UTF-16 encodingschemes and endiannesss thereof in one or more incoming XML data steamsfor XML declarations without a UTF-16 byte-order mark (BOM) or encodingdeclaration. Upon detection and determination of a UTF-16 encodingscheme and endiannesss thereof, the print server may insert anappropriate BOM and further transmit the one or more incoming XML datastreams to one or more printers. This allows for a single device, theprint server, to perform the processing necessary to detect anddetermine UTF-16 encoding schemes and endiannesss thereof in one or moreincoming XML data steams for XML declarations without a UTF-16byte-order mark (BOM) or encoding declaration, thereby allowingsubsequent downstream devices to be able to rely upon BOMs in nowwell-formed XML statements in the XML data stream.

Similarly, as another exemplary embodiment of the present invention, aproprietary software print driver may be used to perform the processingnecessary to detect and determine UTF-16 encoding schemes andendiannesss thereof in one or more incoming XML data steams for XMLdeclarations without a UTF-16 byte-order mark (BOM) or encodingdeclaration, thereby allowing subsequent downstream devices, such as aprinter, to be able to rely upon BOMs in now well-formed XML statementsin the XML data stream.

In like manner, any electronic device that operates between one or moresources of data and one or more other devices may be included in anotherexemplary embodiment of the present invention used to perform theprocessing necessary to detect and determine UTF-16 encoding schemes andendiannesss thereof in one or more incoming XML data steams to theelectronic device for XML declarations without a UTF-16 byte-order mark(BOM) or encoding declaration. For example, a bar code scanner or RFIDtag reader may receive and identify data or XML data encoded on or inother objects such as bar codes or RFID tags, respectively. And the barcode scanner or RFID tag reader, or software associated with the the barcode scanner or RFID tag reader, transmits the received data as XML dataor as part of XML data or transmits the received XML data to anotherdevice. Accordingly, the bar code scanner or RFID tag reader, orsoftware associated with the bar code scanner or RFID tag reader, mayoperate, like a print server might, to automatically determine a UTF-16encoding scheme in the incoming data stream to the bar code scanner orRFID tag reader without a byte-order mark. And, thus, upon detection anddetermination of a UTF-16 encoding scheme and endiannesss thereof, thebar code scanner or RFID tag reader may insert an appropriate BOM andfurther transmit the XML data to one or more other devices.

The printer, system, method, and computer program product embodiments ofthe present invention are primarily described above in conjunction withprinters and printing applications. However, as described above, system,method, and computer program product embodiments of the presentinvention may be utilized in conjunction with a variety of otherapplications. For example, system, method, and computer program productof embodiments of the present invention may be utilized in conjunctionwith wireline and/or wireless networking (e.g., Internet) applications.

Referring now to FIG. 3, a block diagram of an entity that may benefitfrom the present invention is shown. Although shown as separateentities, as described above, in some embodiments, one or more entitiesmay support one or more of a printer and/or computing system, logicallyseparated but co-located within the entity (or entities). For example, asingle entity may support a logically separate, but co-located,computing system and printer. Similarly, one or more entities maysupport one or more of a printer and/or computing system, logicallyseparated but not co-located within the same entity (or entities).

The entity of FIG. 3 includes various means for performing one or morefunctions in accordance with exemplary embodiments of the presentinvention, including those more particularly shown and described herein.It should be understood, however, that an entity may include alternativemeans for performing one or more of the functions or like functions inaccordance with an embodiment of the present invention, withoutdeparting from the spirit and scope of the present invention. Moreparticularly, for example, as shown in FIG. 3, the entity can include aprocessor, controller, or like processing element 328 connected to amemory 326. One or more processors may be used in common as part of thesame platform, or processors may be distributed between subsystems. Thememory can comprise volatile memory 314 and/or non-volatile memory 318,and typically stores content, data, or the like. For example, the memory326 typically stores XML data transmitted from and/or received by theentity and may also store an identification of the current encodingscheme of an incoming data stream. Also for example, the memory 326typically stores computer program code, such as for firmware, softwareprint drivers, operating systems, and client applications, for theprocessor to perform steps associated with operation of the entity inaccordance with embodiments of the present invention. Memory 326 may be,for example, read only memory (ROM), random access memory (RAM), cachememory, a flash drive, a hard drive, and/or other fixed data memory orstorage device, such as described above with respect to the computersystem 112 of FIG. 1.

As described herein, a detection module 330 or like firmware or othercomputer program product code logic, may comprise software operated bythe respective entities. It should be understood, however, thatfirmware, software, or computer program products described herein mayalso comprise one or more hardware elements without departing from thespirit and scope of the present invention. Generally, then, a printer,computing system, or other device or system can include one or morelogic elements for performing various functions in accordance with anembodiment of the present invention. As will be appreciated, the logicelements can be embodied in any of a number of different manners. Inthis regard, the logic elements performing the functions of one or moreclient applications can be embodied in software code logic and/or anintegrated circuit assembly including one or more integrated circuitsintegral or otherwise in communication with a respective entity (i.e., aprinter, computing system, etc.) or more particularly, for example, aprocessor 328 of the respective entity.

In addition to the memory 326, the processor 328 can also be connectedto at least one interface or other means for displaying, transmittingand/or receiving data, content, or the like. In this regard, theinterface(s) can include at least one communication interface 342 orother means for transmitting and/or receiving data, content, or thelike. For example, the communication interface(s) can include a wirelessantenna and communication interface 312, including a transmitter 312 anda receiver 346. Additional communication interfaces, such as for radiofrequency (RF) 360, infrared (IR) 362, Bluetooth (BT) 364, UniversalSerial Bus (USB) 366, IEEE 1394 (Firewire) 368, and network interface(s)370, such as for Ethernet or coaxial connections, may also be included.In addition to the communication interface(s), the interface(s) may alsoinclude a user input interface 332 that can include one or more devices,such as a microphone, a keypad 333, a touch display, a joystick or otherinput device 335. The interface(s) may also include a user outputinterface 334 that can include one or more devices, such as earphonesand/or speakers 338 and a display 337.

The entity may also include a detection module 330 connected to theprocessor 328. As described above, such a module may be software and/orsoftware-hardware components. For example, a detection module 330 mayinclude software and/or software-hardware components capable ofreceiving an incoming data stream and analyzing the incoming data streamto automatically detect and determine UTF-16 encoding schemes andendiannesss thereof in the incoming data steam for XML declarationswithout a UTF-16 byte-order mark (BOM) or encoding declaration.

A computer program product for performing one or more functions ofembodiments of the present invention may include a computer-readable andcomputer-useable storage medium, such as the non-volatile storagemedium, and software including computer-readable program code logicportions, such as a series of computer instructions, embodied in (storedon) the computer-readable and computer-useable storage medium.Similarly, embodiments of the present invention may be incorporated intohardware and software systems and subsystems, combinations of hardwaresystems and subsystems and software systems and subsystems, andincorporated into network devices and systems and mobile stationsthereof.

In this regard, each block or step of the present invention, such asfunctions of the schematic block diagrams and the flow chart, andcombinations of blocks and steps, can be implemented by various means,such as hardware, firmware, and/or software including one or morecomputer program instructions. As will be appreciated, any such computerprogram instructions may be loaded onto a computer or other programmableapparatus (i.e., hardware) to produce a machine, such that theinstructions which execute on the computer or other programmableapparatus create means for implementing the functions specified in theblocks and steps. These computer program instructions may also be storedin a computer-readable memory that can direct a computer or otherprogrammable apparatus to function in a particular manner, such that theinstructions stored in the computer-readable memory produce an articleof manufacture including instruction means which implement the functionsspecified in the blocks and steps. The computer program instructions mayalso be loaded onto a computer or other programmable apparatus to causea series of operational steps to be performed on the computer or otherprogrammable apparatus to produce a computer-implemented process suchthat the instructions that execute on the computer or other programmableapparatus provide steps for implementing the functions specified in theblocks and steps.

Accordingly, blocks and steps of the schematic block diagrams and flowchart support combinations of means for performing the specifiedfunctions, combinations of steps for performing the specified functions,and program instruction means for performing the specified functions. Itwill also be understood that one or more blocks or steps of theschematic block diagrams and flow chart, and combinations of blocks orsteps in the schematic block diagrams and flow chart, can be implementedby special purpose hardware-based computer systems which perform thespecified functions or steps, or combinations of special purposehardware and computer instructions.

As described above and shown in the accompanying figure, printers andother computing devices, systems, methods, and computer program productsof embodiments of the present invention that automatically detect anddetermine UTF-16 encoding schemes and endiannesss thereof in an incomingXML data steam for XML declarations without a UTF-16 byte-order mark(BOM) or encoding declaration are provided. This allows for theautomatic and unambiguous accurate detection of UTF-16 encoded XML datawithin a mixed encoding environment, such as from multiple sources usingmore than one encoding scheme, even when XML data does not start with aBOM or encoding declaration. As noted above, embodiments of the presentinvention also allow for using XML in an environment that supportslegacy devices and systems that use different Unicode and proprietaryencoding schemes and devices and systems that are not XML compliant,i.e., such as devices and systems that are not configured to include aBOM for UTF-16 encoded XML data.

Many modifications and other embodiments of the inventions set forthherein will come to mind to one skilled in the art to which theseinventions pertain having the benefit of the teachings presented in theforegoing descriptions and the associated drawings. Therefore, it is tobe understood that the inventions are not to be limited to the specificembodiments disclosed and that modifications, equivalents, and otherembodiments are intended to be included within the scope of the appendedclaims.

1. A method, comprising automatically determining a UTF-16 encodingscheme in an incoming data stream without a byte-order mark.
 2. Themethod of claim 1, wherein automatically determining a UTF-16 encodingscheme, comprises: receiving structure markup language data in theincoming data stream; and processing the incoming data stream accordingto the automatically determined UTF-16 encoding scheme.
 3. The method ofclaim 1, wherein automatically determining a UTF-16 encoding scheme,comprises: receiving structure markup language data in the incoming datastream; and storing a current encoding status of the incoming datastream as the automatically determined UTF-16 encoding scheme.
 4. Themethod of claim 1, wherein automatically determining a UTF-16 encodingscheme, comprises: receiving XML data in the incoming data stream at aprint server; inserting a byte-order mark into the incoming data streamidentifying the automatically determined UTF-16 encoding scheme of theincoming data stream to create an enhanced incoming data stream; andtransmitting the enhanced incoming XML data stream to a printer.
 5. Themethod of claim 1, wherein automatically determining a UTF-16 encodingscheme, comprises: receiving the incoming data stream; storing a currentencoding status of the incoming data stream; monitoring the incomingdata stream for the presence of a 0x3C byte; when a 0x3C byte isidentified, determining if a byte following the 0x3C byte is a null 0x00byte; and if the byte following the 0x3C byte is a null 0x00 byte and ifthe current encoding status is not UTF-16LE, then: determining if a bytebefore the 0x3C byte is a null 0x00 byte; if the byte before the 0x3Cbyte is a null 0x00 byte, then begin processing the incoming data streamas UTF-16BE and storing the current encoding status of the incoming datastream as UTF-16BE; and if the byte before the 0x3C byte is not a null0x00 byte, then begin processing the incoming data stream as UTF-16LEand storing the current encoding status of the incoming data stream asUTF-16LE.
 6. The method of claim 1, wherein automatically determining aUTF-16 encoding scheme, comprises: receiving the incoming data stream;storing a current encoding status of the incoming data stream;monitoring the incoming data stream for the presence of a 0x3C byte;when a 0x3C byte is identified, determining if a byte following the 0x3Cbyte is a null 0x00 byte; and if the byte following the 0x3C byte is anull 0x00 byte and if the current encoding status is not UTF-16LE, then:determining if a byte before the 0x3C byte is a null 0x00 byte; and ifthe byte before the 0x3C byte is a null 0x00 byte, then begin processingthe incoming data stream as UTF-16BE and storing the current encodingstatus of the incoming data stream as UTF-16BE.
 7. The method of claim1, wherein automatically determining a UTF-16 encoding scheme,comprises: receiving the incoming data stream; storing a currentencoding status of the incoming data stream; monitoring the incomingdata stream for the presence of a 0x3C byte; when a 0x3C byte isidentified, determining if a byte following the 0x3C byte is a null 0x00byte; and if the byte following the 0x3C byte is a null 0x00 byte and ifthe current encoding status is not UTF-16LE, then: determining if a bytebefore the 0x3C byte is a null 0x00 byte; and if the byte before the0x3C byte is not a null 0x00 byte, then begin processing the incomingdata stream as UTF-16LE and storing the current encoding status of theincoming data stream as UTF-16LE.
 8. The method of claim 1, whereinautomatically determining a UTF-16 encoding scheme, comprises: receivingthe incoming data stream; storing a current encoding status of theincoming data stream; monitoring the incoming data stream for thepresence of a 0x3C byte; when a 0x3C byte is identified, determining ifa byte following the 0x3C byte is a null 0x00 byte; and if the bytefollowing the 0x3C byte is a null 0x00 byte and if the current encodingstatus is UTF-16LE, then: determining if the two bytes before the 0x3Cbyte are null 0x00 bytes; if the two bytes before the 0x3C byte are null0x00 bytes, then begin processing the incoming data stream as UTF-16BEand storing the current encoding status of the incoming data stream asUTF-16BE; and if the two bytes before the 0x3C byte are not null 0x00bytes, then begin processing the incoming data stream as UTF-16LE andstoring the current encoding status of the incoming data stream asUTF-16LE.
 9. The method of claim 1, wherein automatically determining aUTF-16 encoding scheme, comprises: receiving the incoming data stream;storing a current encoding status of the incoming data stream;monitoring the incoming data stream for the presence of a 0x3C byte;when a 0x3C byte is identified, determining if a byte following the 0x3Cbyte is a null 0x00 byte; and if the byte following the 0x3C byte is anull 0x00 byte and if the current encoding status is UTF-16LE, then:determining if the two bytes before the 0x3C byte are null 0x00 bytes;and if the two bytes before the 0x3C byte are null 0x00 bytes, thenbegin processing the incoming data stream as UTF-16BE and storing thecurrent encoding status of the incoming data stream as UTF-16BE.
 10. Themethod of claim 1, wherein automatically determining a UTF-16 encodingscheme, comprises: receiving the incoming data stream; storing a currentencoding status of the incoming data stream; monitoring the incomingdata stream for the presence of a 0x3C byte; when a 0x3C byte isidentified, determining if a byte following the 0x3C byte is a null 0x00byte; and if the byte following the 0x3C byte is a null 0x00 byte and ifthe current encoding status is UTF-16LE, then: determining if the twobytes before the 0x3C byte are null 0x00 bytes; and if the two bytesbefore the 0x3C byte are not null 0x00 bytes, then begin processing theincoming data stream as UTF-16LE and storing the current encoding statusof the incoming data stream as UTF-16LE.
 11. The method of claim 1,wherein the incoming data stream comprises XML data.
 12. A electronicdevice, comprising a processor configured for receiving structure markuplanguage data without a byte-order mark in an incoming data stream andautomatically determining a UTF-16 encoding scheme of the structuremarkup language data without a byte-order mark.
 13. The electronicdevice of claim 12, wherein the structure markup language data is XMLdata.
 14. The electronic device of claim 12, wherein the electronicdevice comprises a printer.
 15. The electronic device of claim 12,wherein the electronic device comprises a print server.
 16. Theelectronic device of claim 12, wherein the electronic device comprises asoftware print driver.
 17. The electronic device of claim 12, whereinthe electronic device comprises a bar code scanner.
 18. The electronicdevice of claim 12, wherein the electronic device comprises an RFIDreader/writer.
 19. A printing system, comprising: a first electronicdevice; a print server communicatively connected to the first electronicdevice and configured to receive data from the first electronic devicein an incoming data stream received by the print server, wherein theprinter comprises an XML processor configured to: process the incomingdata stream to automatically determine a UTF-16 encoding scheme in theincoming data stream without a byte-order mark, insert a byte-order markinto the incoming data stream identifying the automatically determinedUTF-16 encoding scheme of the incoming data stream to create an enhancedincoming data stream, and transmit the enhanced incoming data stream;and a printer communicatively connected to the print server andconfigured to receive the enhanced incoming data stream.